<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定时器-时钟</title>
    <style>
        h1{
            text-align: center;
            background-color: aquamarine;
        }
    </style>
</head>
<body>
    <h1 id="count">0</h1>
    <h1 id="count2">0</h1>
</body>
</html>
<script>
    /*
        制作一个时钟，能以 60 秒进一的进制运行
    */

    // 时 h
    var h = 0;
    // 分 min
    var min = 0;
    // 秒 s
    var s = 0;
    // 毫秒
    var ms = 0;

    // 获取id 为count
    var count = document.getElementById("count");
    var count2 = document.getElementById("count2");

    function timer(){
        ms+=10;
        if(ms == 1000){
            s++;
            ms=0;
        }
        if(s == 60){
            min++;
            s=0;
        }
        if(min == 60){
            h++;
            min=0;
        }
        count.innerHTML = h+" : "+min+" : "+s;
        count2.innerHTML = ms+"毫秒";
    }
    setInterval(timer,10);
</script>